package ru.urfc.portal.model.radio;

import java.util.List;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

import ru.urfc.portal.model.SpectrObjectWithContragent;
import ru.urfc.portal.model.accounting.Contragent;
import ru.urfc.portal.model.catalogs.NetState;
import ru.urfc.portal.ui.client.Constants;

@Table(name = "portal_nets")
@Entity
@XmlRootElement(name = Constants.NET)
public class NetWithLicense extends SpectrObjectWithContragent {

	@OneToMany(mappedBy = "net")
	private List<Device> devices;
	@Transient
	private NetLicense currentLicense;
	public String name;
	@Transient
	private String region;
	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn (name = "netState_code")
	public NetState state;
	
	public NetWithLicense() {
		super();
	}
	
	public NetWithLicense(Contragent contragent, String name, String region, NetState state) {
		super(contragent);
		this.name = name;
		this.region = region;
		this.state = state;
	}
	
	public NetWithLicense(Contragent contragent) {
		super(contragent);
	}

	@XmlTransient
	public List<Device> getDevices() {
		return devices;
	}

	public NetLicense getCurrentLicense() {
		return currentLicense;
	}
	
	public void setCurrentLicense(NetLicense currentLicense) {
		this.currentLicense = currentLicense;
	}

	public String getRegion() {
		return region;
	}

	public void setRegion(String region) {
		this.region = region;
	}
	
}
